<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class clase extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index(){
		//$this->load->view('welcome_message');
		$this->load->helper('security');
		$this->load->model('usuario_model');
		
// 		$this->usuario_model->insert_entry(
// 				'fredy.alvarino'. time(),
// 				do_hash('FredyAlvarino', 'md5'),
// 				'A',
// 				'SuperUser',
// 				1
// 				);
		
		$this->usuario_model->count();
		
	} // End-index-function
	
	
	function consultadb(){
		$localdb = $this->load->database('local', TRUE);

		//$sql = "SELECT * FROM tb WHERE id = ? AND status = ? AND author = ?";
		//$localdb->query($sql, array(3, 'live', 'Rick'));
		
		$query = $localdb->query('SELECT Count(*) FROM TBUSR');
		
		echo "<table border='1'>\n";
		foreach ($query->result() as $row){
			echo "<tr>\n";
			foreach ($row as $item) {
				echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
			}
			echo "</tr>\n";
		}
		echo "</table>\n";
		
		echo 'Total Results: ' . $query->num_rows();
		
		$localdb->close();
	}
	
	function tales(){
		//$this->load->view('welcome_message');
		
		$this->load->database();
		
		$query = $this->db->query('SELECT paquete_consultas_varias.info_alumno(\'1076327736\') FROM DUAL');
		
		
		echo "<table border='1'>\n";
		foreach ($query->result() as $row){
			echo "<tr>\n";
			foreach ($row as $item) {
				echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
			}
			echo "</tr>\n";
		}
		echo "</table>\n";
		
		echo 'Total Results: ' . $query->num_rows();
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */